<%-- 
    Document   : dccrcontent
    Created on : May 4, 2011, 2:12:01 AM
    Author     : MacBook
--%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<div id="ccrcontent">
    <hr/>
    <s:set name="stat" value="stat"/>
    <s:if test="%{#stat!=undefined}">
        <s:if test="%{#stat!='ok'}">
            <dl class="ui-state-error ui-corner-all">
                <dt><span class="ui-icon ui-icon-alert"></span><s:property value="#stat"/></dt>
            </dl>
        </s:if>
        <s:elseif test="%{#stat=='ok'}">
            <dl class="ui-state-highlight ui-corner-all" style="clear:both">
                <dt><span class="ui-icon ui-icon-info"></span>Cash Custodian Report posted!</dt>
            </dl>
        </s:elseif>
    </s:if>
    <s:if test="%{#privilegeView.allowable == false}">
        <script type="text/javascript">window.location="home.jsp";</script>
    </s:if>
    <s:if test="%{#privilegeCreate.allowable == false}">
        <dl class="ui-state-highlight ui-corner-all" style="clear:both">
            <dt><span class="ui-icon ui-icon-info"></span>You are not allowed to create in this module.</dt>
        </dl>
        <script type="text/javascript">
            $(document).ready(function(){
                $('#dateccr').attr("disabled","disabled");
            });
        </script>
    </s:if>
    <s:if test="%{#request.latestccr == null}">
        <script type="text/javascript">
            $(document).ready(function(){
                $('#beginbalcib').val(0);
                $('#beginbalcoh').val(0);
                $('#beginbaltotal').val(0);
            });
        </script>
    </s:if>
    <s:if test="view!='yes'">
        <s:form action="view-ccr" id="ccrinfo" cssStyle="overflow: auto; padding: 0;font-size: 12px;width:990px;" theme="simple" name="custodian" >
            <table id="first">
                <s:if test="#session.branch.branchname=='Head Office'">
                    <tr>
                        <td><s:label>Branch</s:label></td>
                        <td><s:action executeResult="false" name="get-branch" var="br"/>
                            <s:select label="Branch"
                                      id="branch"
                                      name="branch"
                                      list="#br.brList"
                                      listKey ="branchid"
                                      listValue="branchname"
                                      headerKey="-1"
                                      emptyOption="false"
                                      cssStyle="width:150px;"
                                      headerValue="Select Branch"
                                      value="Urdaneta"
                                      readonly="true"
                                      /></td>
                    </tr>
                </s:if>
                <s:else>
                    <tr>
                        <td><s:label>Branch</s:label></td>
                        <td><s:textfield id="branch" value="%{#session['branch'].branchname}" readonly="true"/></td>
                        <s:textfield name="branch" value="%{#session['branch'].branchid}" cssStyle="display:none"/>
                    </tr>
                </s:else>
                <tr>
                    <td><s:label>Employee Code</s:label></td>
                    <td><s:textfield id="empcode" value="%{#session['employee'].idnumber}" readonly="true"/></td>
                    <td>&nbsp;</td>
                    <td><s:label>Employee Name</s:label></td>
                    <td><s:textfield id="empname" value="%{#session['employee'].completename}" readonly="true"/></td>
                </tr>
                <tr>
                    <td><s:label>Bank Code</s:label></td>
                    <td><s:textfield id="bankcode" name="bankcode"/></td>
                    <td>&nbsp;</td>
                    <td><s:label>Bank Account No.</s:label></td>
                    <td><s:textfield id="acctnum" name="acctnum" value="%{#session['branch'].bankaccountnum}" readonly="true"/></td>
                </tr>
                <tr>
                    <td><s:label>Date</s:label></td>
                    <td><sj:datepicker id="dateccr" name="date"/></td>
                </tr>
            </table>
        </s:form>
    </s:if>
    <s:elseif test="view=='yes'">
        <hr/>
        <s:form action="save-ccr" theme="simple" cssStyle="overflow: auto; padding: 0;font-size: 12px;width:990px;" id="ccreport">
            <table id="first">
                <s:if test="#session.branch.branchname=='Head Office'">
                    <tr>
                        <td><s:label>Branch</s:label></td>
                        <td><s:textfield id="branch" name="branch" value="%{#request.branchccr.branchname}" readonly="true"/></td>
                        <s:textfield name="branchid" value="%{#request.branchccr.branchid}" cssStyle="display:none"/>

                    </tr>
                </s:if>
                <s:else>
                    <tr>
                        <td><s:label>Branch</s:label></td>
                        <td><s:textfield id="branch" name="branch" value="%{#session['branch'].branchname}" readonly="true"/></td>
                    </tr>
                </s:else>
                <tr>
                    <td><s:label>Employee Code</s:label></td>
                    <td><s:textfield id="empcode" name="empcode" value="%{#session['employee'].idnumber}" readonly="true"/></td>
                    <td>&nbsp;</td>
                    <td><s:label>Employee Name</s:label></td>
                    <td><s:textfield id="empname" name="empname" value="%{#session['employee'].completename}" readonly="true"/></td>
                </tr>
                <tr>
                    <td><s:label>Bank Code</s:label></td>
                    <td><s:textfield id="bankcode" name="bankcode" value="%{#request.bankcode}"/></td>
                    <td>&nbsp;</td>
                    <td><s:label>Bank Account No.</s:label></td>
                    <td><s:textfield id="acctnum" name="acctnum" value="%{#session['branch'].bankaccountnum}" readonly="true"/></td>
                </tr>
                <tr>
                    <td><s:label>Date</s:label></td>
                    <td><sj:datepicker id="dateccr" name="date" value="%{#request.date}"/></td>
                </tr>
            </table>

            <table id="second">
                <tr>
                    <td>&nbsp;</td>
                    <th><s:label>Beginning Balance</s:label></th>
                    <th><s:label>Deposit in Transit</s:label></th>
                    <th><s:label>Collections</s:label></th>
                    <th><s:label>Disbursement</s:label></th>
                    <th><s:label>Additional Funds</s:label></th>
                    <th><s:label>Bank Debit Memo</s:label></th>
                    <th><s:label>Bank Credit Memo</s:label></th>
                    <th><s:label>Ending Balance</s:label></th>
                </tr>
                <tr>
                    <td><s:label>Cash in Bank</s:label></td>
                    <s:if test="#session.branch.branchname=='Head Office'">
                        <td><s:textfield id="beginbalcib" name="beginbalcib" value="%{#request.latestccr.endbalcib}"/></td>
                    </s:if>
                    <s:else>
                        <td><s:textfield id="beginbalcib" name="beginbalcib" value="0" cssStyle="display:none"/></td>
                    </s:else>
                    <td><s:textfield id="depintransitcib" name="depintransitcib"/></td>
                    <td><s:textfield id="collectioncib" name="collectioncib"/></td>
                    <td><s:textfield id="disbursementcib" name="disbursementcib"/></td>
                    <td><s:textfield id="addtlfundcib" name="addtlfundcib"/></td>
                    <td><s:textfield id="bankdebitmemocib" name="bankdebitmemocib"/></td>
                    <td><s:textfield id="bankcreditmemocib" name="bankcreditmemocib"/></td>
                    <s:if test="#session.branch.branchname=='Head Office'">
                        <td><s:textfield id="endbalcib" name="endbalcib"/></td>
                    </s:if>
                    <s:else>
                        <td><s:textfield id="endbalcib" name="endbalcib" value="0" cssStyle="display:none"/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label>Cash on Hand</s:label></td>
                    <td><s:textfield id="beginbalcoh" name="beginbalcoh" value="%{#request.latestccr.endbalcoh}"/></td>
                    <td><s:textfield id="depintransitcoh" name="depintransitcoh" value="0"/></td>
                    <td><s:textfield id="collectioncoh" name="collectioncoh"/></td>
                    <td><s:textfield id="disbursementcoh" name="disbursementcoh"/></td>
                    <td><s:textfield id="addtlfundcoh" name="addtlfundcoh"/></td>
                    <td><s:textfield id="bankdebitmemocoh" name="bankdebitmemocoh"/></td>
                    <td><s:textfield id="bankcreditmemocoh" name="bankcreditmemocoh"/></td>
                    <td><s:textfield id="endbalcoh" name="endbalcoh"/></td>
                </tr>
                <tr>
                    <td><s:label>Total Cash</s:label></td>
                    <td><s:textfield id="beginbaltotal" name="beginbaltotal" value="%{#request.latestccr.endbaltotal}"/></td>
                    <td><s:textfield id="depintransittotal" name="depintransittotal"/></td>
                    <td><s:textfield id="collectiontotal" name="collectiontotal"/></td>
                    <td><s:textfield id="disbursementtotal" name="disbursementtotal"/></td>
                    <td><s:textfield id="addtlfundtotal" name="addtlfundtotal"/></td>
                    <td><s:textfield id="bankdebitmemototal" name="bankdebitmemototal"/></td>
                    <td><s:textfield id="bankcreditmemototal" name="bankcreditmemototal"/></td>
                    <td><s:textfield id="endbaltotal" name="endbaltotal"/></td>
                </tr>
            </table>

            <hr/>

            <sj:tabbedpanel id="tabpanel" value="tab">
                <sj:tab id="tab1" target="deposit" label="Deposit in Transit" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab2" target="collection" label="Collections" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab3" target="check" label="Check Disbursement" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab4" target="cash" label="Cash Disbursement" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab5" target="addtlfund" label="Additional Funds" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab6" target="bankdebit" label="Bank Debit Memo" cssStyle="font-size:12px;"></sj:tab>
                <sj:tab id="tab6" target="bankcredit" label="Bank Credit Memo" cssStyle="font-size:12px;"></sj:tab>
                <%--<sj:tab id="tab7" target="pettycash" label="Petty Cash Fund" cssStyle="font-size:12px;"></sj:tab>--%>

                <!--Deposit in Transit-->
                <s:div id="deposit" theme="simple" cssStyle="font-size:12px;">  
                    <table>
                        <tr >
                            <td><s:label>Deposit Slip No.</s:label></td>
                            <td><s:textfield id="depositslipnum" name="depositslipnum"/></td>

                            <td><s:label>Date Deposited</s:label></td>
                            <td><sj:datepicker id="datedeposit" name="datedeposit"/></td>

                            <td><s:label >Amount</s:label></td>
                            <td><s:textfield id="depositamount" name="depositamount"/></td>
                        </tr>
                    </table>
                    <br/>

                    <table border="1px" cellspacing="0" style="width:500px">
                        <thead>
                            <tr>
                                <th>Area</th>
                                <th>Collector</th>
                                <th>Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            <s:iterator value="#request.colldeposit">
                                <tr class ="deptr">
                                    <td><label><s:property value="areacode"/></label></td>
                                    <td><label><s:property value="collector"/></label></td>
                                    <td><label class="depamount"><s:property value="cashonhand"/></label></td>
                            <input name="depositid" style="display:none" value="<s:property value="collectionid"/>"/>

                            </tr>
                        </s:iterator>
                        </tbody>
                    </table>
                </s:div>
                <!--Collections-->
                <s:div id="collection" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0" style="margin-left: -1em">
                        <thead>
                            <tr>
                                <th>Area Code</th>
                                <th>Collector Code</th>
                                <th>Collector</th>
                                <th>Document</th>
                                <th>Document Date</th>
                                <th>Deposit Slip No.</th>
                                <th>Cash in Bank</th>
                                <th>Cash on Hand</th>
                                <th>Total Collection</th>
                            </tr>
                        </thead>
                        <tbody>
                            <s:iterator value="#request.collection">

                                <tr class="colltr">
                                    <td><label><s:property value="areacode"/></label></td>
                                    <td><label><s:property value="areas.employees.employeeid"/></label></td>
                                    <td><label><s:property value="areas.collector"/></label></td>
                                    <td><label><s:property value="documents.documenttype"/></label></td>
                                    <td><label><s:property value="documents.documentdate"/></label></td>
                                    <td><label><s:property value="depositno"/></label></td>
                                    <td><label class="collcib"><s:property value="depositamount"/></label></td>
                                    <td><label class="collcoh"><s:property value="cashonhand"/></label></td>
                                    <td><label><s:property value="totalamountcollected"/></label></td>
                            <input name="collectionid" style="display:none" value="<s:property value="collectionid"/>"/>

                            </tr>
                        </s:iterator>
                        <c:if test="${request.collection != undefined}">
                            <script type="text/javascript">
                                $(document).ready(function(){
                                    var coll = $('.collcoh').length;
                                    var cibcoll = $('.collcib').length;
                                    var cibdep = $('.depamount').length;
                                    var check = $('.clonecheck').length;
                                    var sumcoll =0;
                                    var sumcollcib =0;
                                    var sumcibdep =0;
                                    var sumchecks =0;
                                    
                                    $('#addtlfundcib').val(0);
                                    $('#addtlfundtotal').val(0);
                                    $('#bankdebitmemocib').val(0);
                                    $('#bankdebitmemototal').val(0);
                                    $('#bankcreditmemocib').val(0);
                                    $('#bankcreditmemototal').val(0);
                                    
                                    for(var i=0;i<check;i++){
                                        sumchecks = sumchecks + parseFloat($('.clonecheck'.concat(':nth-child(',i+1,')',' td label.checkamount')).text());
                                    }
                                    for(var i=0;i<cibdep;i++){
                                        sumcibdep = sumcibdep + parseFloat($('.deptr'.concat(':nth-child(',i+1,')',' td label.depamount')).text());
                                    }
                                    for(var i=0;i<cibcoll;i++){
                                        sumcollcib = sumcollcib + parseFloat($('.colltr'.concat(':nth-child(',i+1,')',' td label.collcib')).text());
                                    }
                                    for(var i=0;i<coll;i++){    //Cash on Hand
                                        sumcoll = sumcoll + parseFloat($('.colltr'.concat(':nth-child(',i+1,')',' td label.collcoh')).text());
                                    }
                                    
                                    $('#collectioncoh').val(sumcoll);      
                                    $('#collectioncib').val(sumcollcib);
                                    $('#collectiontotal').val(sumcollcib+sumcoll);
                                    $('#depintransitcib').val(sumcibdep);
                                    $('#depintransitcoh').val(0);
                                    $('#depintransittotal').val(sumcibdep);
                                    $('#disbursementcib').val(sumchecks);
                                    $('#disbursementtotal').val(sumchecks);
                                    
                                    var checkdisbursement =0;
                                    checkdisbursement = sumchecks;

                                    function computeEndbal(field){
                                        var beginbalcib = parseFloat($('#beginbalcib').val());
                                        var depintransitcib = parseFloat($('#depintransitcib').val());
                                        var collectioncib = parseFloat($('#collectioncib').val());
                                        var disbursementcib = parseFloat($('#disbursementcib').val());
                                        var addtlfundcib = parseFloat($('#addtlfundcib').val());
                                        var bankdebitmemocib = parseFloat($('#bankdebitmemocib').val());
                                        var bankcreditmemocib = parseFloat($('#bankcreditmemocib').val());
                                        var endbalcib = parseFloat($('#endbalcib').val());
                         
                                        var beginbalcoh = parseFloat($('#beginbalcoh').val());
                                        var depintransitcoh = parseFloat($('#depintransitcoh').val());
                                        var collectioncoh = parseFloat($('#collectioncoh').val());
                                        var disbursementcoh = parseFloat($('#disbursementcoh').val());
                                        var addtlfundcoh = parseFloat($('#addtlfundcoh').val());
                                        var bankdebitmemocoh = parseFloat($('#bankdebitmemocoh').val());
                                        var bankcreditmemocoh = parseFloat($('#bankcreditmemocoh').val());
                                        var endbalcoh = parseFloat($('#endbalcoh').val());
                         
                                        var beginbaltotal = parseFloat($('#beginbaltotal').val());
                                        var depintransittotal = parseFloat($('#depintransittotal').val());
                                        var collectiontotal = parseFloat($('#collectiontotal').val());
                                        var disbursementtotal = parseFloat($('#disbursementtotal').val());
                                        var addtlfundtotal = parseFloat($('#addtlfundtotal').val());
                                        var bankdebitmemototal = parseFloat($('#bankdebitmemototal').val());
                                        var bankcreditmemototal = parseFloat($('#bankcreditmemototal').val());
                                        var endbaltotal =parseFloat($('#endbaltotal').val());

                                        if(field=="cib"){
                                            
                                            var total = beginbalcib+depintransitcib+collectioncib-disbursementcib+addtlfundcib-bankdebitmemocib+bankcreditmemocib;
                                            $('#endbalcib').val(total)
                                        }else if(field=="coh"){
                                            var total = beginbalcoh+depintransitcoh+collectioncoh-disbursementcoh+addtlfundcoh-bankdebitmemocoh+bankcreditmemocoh;
                                            $('#endbalcoh').val(total)
                                        }
                                        computeTotalEndBal();
                                    }
                                    
                                    function computeTotalEndBal(){
                                        var endbalcib = parseInt($('#endbalcib').val());
                                        var endbalcoh = parseInt($('#endbalcoh').val());
                                        $('#endbaltotal').val(endbalcib+endbalcoh);
                                    }

                                    function computeTotalCashD(){
                                        var length = $('.cashamount').length;
                                        var sum=0;
                                        var item=0;
                                        for(var i=0; i<length;i++){
                                            item = $('.clonecash:nth-child('.concat(i+1,')',' td input.cashamount')).val();
                                            if(item!=""){
                                                sum=sum+parseFloat(item);
                                            }
                                        }
                                                
                                        $('#disbursementcib').val(sum+parseFloat(checkdisbursement));
                                        $('#disbursementtotal').val(parseFloat($('#disbursementcoh').val())+parseFloat($('#disbursementcib').val()));
                                        computeEndbal("cib");
                                    }
                        
                                    $('.cashamount').keyup(function(e){
                                        computeTotalCashD();
                                    });
                                    
                                    //ADD ROW FOR CASH DISBURSEMENT
                                    var cashctr=1;
                                    $('.cashamount').bind('keypress click',function(e){
                                        var code= (e.keyCode ? e.keyCode : e.which);
                                        if((e.type=='keypress'&&code==13&&((this.id=="lastcash")||cashctr==1))||(e.type=='click'&&this.id=="addcashbtn")){
                                            if(cashctr==1){
                                                //                                                $('#clonecash').removeAttr("style");
                                                //                                                $("<tr></tr>").attr("id", "clonecash").addClass("clonecash").insertAfter($('#cashtbody'));
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashseries").css("width","50px").val("1")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashpayeefname").attr("name","cashpayeefname").css("width","100px")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashpayeemname").attr("name","cashpayeemname")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashpayeelname").attr("name","cashpayeelname")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashparticular").attr("name","cashparticular")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashdocnum").attr("name","cashdocnum")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","cashamount").attr("name","cashamount").addClass("cashamount")))
                                                //                                                $('#clonecash').append($("<td></td>").append($("<input></input>").attr("id","removebtncash").addClass("removebtn").css("width","60px").val("Remove").attr("type","button")))
                                                //                                                
                                                
                                                $('#clonecash').clone(true).attr('id','clonecash'.concat(cashctr)).insertAfter($('#clonecash'));
                                                $('#clonecash nth-child(7)').find('input').attr('id','cashamount');
                                            }else{
                                                $('#clonecash').clone(true).attr('id','clonecash'.concat(cashctr)).insertAfter($('#clonecash'.concat(cashctr-1)));
                                                $('#clonecash'.concat(cashctr-1, ' td:nth-child(7)')).find('input').attr('id','cashamount'.concat(cashctr-1));
                                            }
                                            $('#clonecash'.concat(cashctr, ' td')).find('input').attr('value','');
                                            $('#clonecash'.concat(cashctr, ' td:first')).find('input').attr('value',cashctr+1);

                                            $('#clonecash'.concat(cashctr, ' td:first')).find('input').attr('id','cashseries'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(2)')).find('input').attr('id','cashpayeefname'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(3)')).find('input').attr('id','cashpayeemname'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(4)')).find('input').attr('id','cashpayeelname'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(5)')).find('input').attr('id','cashparticular'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(6)')).find('input').attr('id','cashdocnum'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(7)')).find('input').attr('id','lastcash');
                                            $('#clonecash'.concat(cashctr, ' td:last')).find('input').attr('id','removebtncash'.concat(cashctr));
                                            $('#clonecash'.concat(cashctr, ' td:last')).find('input').attr('value','Remove');
                                            $('#clonecash'.concat(cashctr, ' td:nth-child(2)')).find('input').focus();
                                
                                            cashctr++;
                                        }
                                    });
                                    
                                    $('.removebtn').click(function(e){
                                        var id=this.id;
                          
                                        if(id.indexOf('removebtncash')!=-1){
                                            var num=id.substr(13);
                                            var last = $('.clonecash:last').attr("id").substr(9);
                                            if(id=="removebtncash"){
                                                $('#clonecash').remove();
                                                $('.clonecash:first').attr('id','clonecash');
                                                $('.clonecash:first td:last input').attr('id','removebtncash');      
                                                $('.clonecash:first td:first input').val(1);
                                                cashctr=1;
                                            }else{
                                                $('#clonecash'.concat(num)).remove();

                                                if(num==(parseInt(last)+1)){    //last
                                                    cashctr=parseInt(last)+1;
                                                }else{
                                                    cashctr = parseInt(last)
                                                }
                                            }
                                            for(var i=1;i<last+1;i++){
                                                $('.clonecash'.concat(':nth-child('.concat(i+1,')'))).attr('id','clonecash'.concat(i));
                                                $('#clonecash'.concat(i, ' td:first')).find('input').attr('value',i+1);
                                        
                                                $('#clonecash'.concat(i, ' td:first')).find('input').attr('id','cashseries'.concat(i));
                                                $('#clonecash'.concat(i, ' td:nth-child(2)')).find('input').attr('id','cashpayeefname'.concat(i));
                                                $('#clonecash'.concat(i, ' td:nth-child(3)')).find('input').attr('id','cashpayeemname'.concat(i));
                                                $('#clonecash'.concat(i, ' td:nth-child(4)')).find('input').attr('id','cashpayeelname'.concat(i));
                                                $('#clonecash'.concat(i, ' td:nth-child(5)')).find('input').attr('id','cashparticular'.concat(i));
                                                $('#clonecash'.concat(i, ' td:nth-child(6)')).find('input').attr('id','cashdocnum'.concat(i));
                                                $('#clonecash'.concat(i, ' td:last')).find('input').attr('id','removebtncash'.concat(i));
                                            }
                                            $('.cashamount:last').attr("id", "lastcash");
                                            computeTotalCashD();

                                        }
                                      
                                    });
                                    //CASH DISBURSEMENT NAVIGATION
                                    $('.clonecash').keypress(function(e){
                                        var code= (e.keyCode ? e.keyCode : e.which);
                                        if(code==13){
                                            var id = e.target.id;
                                            if(id.indexOf("cashpayeefname")!="-1"){
                                                var num = id.substr(14);
                                                $('#cashpayeemname'.concat(num)).focus();
                                            }else if(id.indexOf("cashpayeemname")!="-1"){
                                                var num = id.substr(14);
                                                $('#cashpayeelname'.concat(num)).focus();
                                            }else if(id.indexOf("cashpayeelname")!="-1"){
                                                var num = id.substr(14);
                                                $('#cashparticular'.concat(num)).focus();
                                            }else if(id.indexOf("cashparticular")!="-1"){
                                                var num = id.substr(14);
                                                $('#cashdocnum'.concat(num)).focus();
                                            }else if(id.indexOf("cashdocnum")!="-1"){
                                                var num = id.substr(10);
                                                if(cashctr==1){
                                                    $('#cashamount').focus();
                                                }else if(cashctr-1 ==num){
                                                    $('#lastcash').focus();
                                                }else{
                                                    $('#cashamount'.concat(num)).focus();
                                                }
                                            }
                                        }
                                    });
                                    computeEndbal("cib");
                                    computeEndbal("coh");
                                });
                            </script>
                        </c:if>
                        </tbody>
                    </table>
                </s:div>
                <!--Check Disbursement-->
                <s:div id="check" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Borrower</th>
                                <th>Check No.</th>
                                <th>Check Date</th>
                                <th>Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            <s:iterator value="#request.checklist">

                                <tr class="clonecheck">
                                    <td style="width:180px"><label><s:property value="completename"/></label></td>
                                    <td style="width:150px"><label><s:property value="checkno"/></label></td>
                                    <td style="width:150px"><label><s:property value="checkdate"/></label></td>
                                    <td style="width:150px"><label class="checkamount"><s:property value="checkamount"/></label></td>
                            <input name="checkid" style="display:none" value="<s:property value="checkid"/>"/>

                            </tr>
                        </s:iterator>
                        <%--                            <tr id="clonecheck" class="clonecheck">
                                                        <td><s:textfield cssStyle="width:50px;" id="checkseries" value="1"/></td>
                                                        <td><s:textfield id="checkborrower" name="checkborrower"/></td>
                                                        <td><s:textfield id="checknumber" name="checknumber"/></td>
                                                        <td><s:textfield id="checkdate" name="checkdate"/></td>
                                                        <td><s:textfield id="checkamount" name="checkamount" cssClass="lastfield"/></td>
                                                        <td><input id="removebtncheck" class="removebtn" type="button" value="Remove" /></td>
                                                    </tr>--%>
                        </tbody>
                    </table>
                </s:div>  

                <!--Cash Disbursement-->
                <s:div id="cash" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Series</th>
                                <th><label>Payee Firstname</label></th>
                                <th><label>Payee Middlename</label></th>
                                <th><label>Payee Lastname</label></th>
                                <th><label>Particulars</label></th>
                                <th><label>Document No.</label></th>
                                <th><label>Amount</label></th>
                                <%--<th><input id="addcashbtn" class="cashamount" value="Add" type="button" style="width:50px"/></th>--%>
                            </tr>
                        </thead>
                        <tbody id="cashtbody">
                            <tr id="clonecash" class="clonecash">
                                <td><s:textfield cssStyle="width:50px;" id="cashseries" value="1"/></td>
                                <td><s:textfield id="cashpayeefname" name="cashpayeefname" cssStyle="width:100px"/></td>
                                <td><s:textfield id="cashpayeemname" name="cashpayeemname"/></td>
                                <td><s:textfield id="cashpayeelname" name="cashpayeelname"/></td>
                                <td><s:textfield id="cashparticular" name="cashparticular"/></td>
                                <td><s:textfield id="cashdocnum" name="cashdocnum"/></td>
                                <td><s:textfield id="cashamount" name="cashamount" cssClass="cashamount"/></td>
                                <td><input id="removebtncash" class="removebtn" value="Remove" type="button" style="width:60px"/></td>
                            </tr>
                        </tbody>
                    </table>
                </s:div>

                <!--Additional Funds-->
                <s:div id="addtlfund" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Series</th>
                                <th><label>Payee Firstname</label></th>
                                <th><label>Payee Middlename</label></th>
                                <th><label>Payee Lastname</label></th>
                                <th><label>Particulars</label></th>
                                <th><label>Document No.</label></th>
                                <th><label>Amount</label></th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="clonefund" class="clonefund">
                                <td><s:textfield cssStyle="width:50px;" id="seriesfund" value="1"/></td>
                                <td><s:textfield id="payeefundfname" name="payeefundfname"/></td>
                                <td><s:textfield id="payeefundmname" name="payeefundmname"/></td>
                                <td><s:textfield id="payeefundlname" name="payeefundlname"/></td>
                                <td><s:textfield id="particularfund" name="particularfund"/></td>
                                <td><s:textfield id="docnumfund" name="docnumfund"/></td>
                                <td><s:textfield id="amountfund" name="amountfund" cssClass="amountfund"/></td>
                                <td><input id="removebtnfund" class="removebtn" value="Remove" type="button" style="width:60px"/></td>
                            </tr>
                        </tbody>
                    </table>
                </s:div>



                <!--Bank Debit Memo-->
                <s:div id="bankdebit" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Series</th>
                                <th>Particulars</th>
                                <th>Amount</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="clonedebit" class="clonedebit">
                                <td><s:textfield cssStyle="width:50px;" id="seriesdebit" value="1"/></td>
                                <td><s:textfield id="particulardebit" name="particulardebit"/></td>
                                <td><s:textfield id="amountdebit" name="amountdebit" cssClass="amountdebit"/></td>
                                <td><input id="removebtndebit" class="removebtn" value="Remove" type="button"/></td>
                            </tr>
                        </tbody>
                    </table>
                </s:div>

                <!--Bank Credit Memo-->
                <s:div id="bankcredit" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Series</th>
                                <th>Particulars</th>
                                <th>Amount</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="clonecredit" class="clonecredit">
                                <td><s:textfield cssStyle="width:50px;" id="seriescredit" value="1"/></td>
                                <td><s:textfield id="particularcredit" name="particularcredit"/></td>
                                <td><s:textfield id="amountcredit" name="amountcredit" cssClass="amountcredit"/></td>
                                <td><input id="removebtncredit" class="removebtn" value="Remove" type="button"/></td>
                            </tr>
                        </tbody>
                    </table>
                </s:div>

                <!--Petty Cash Fund-->
                <%--<s:div id="pettycash" theme="simple" cssStyle="font-size:12px;">
                    <table border="1px" cellspacing="0">
                        <thead>
                            <tr>
                                <th>Series</th>
                                <th>Payee</th>
                                <th>Particulars</th>
                                <th>Document No.</th>
                                <th>Document Date</th>
                                <th>Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="clonepetty">
                                <td><s:textfield cssStyle="width:50px;" id="seriespetty" value="1"/></td>
                                <td><s:textfield id="payeepetty" name="payeepetty"/></td>
                                <td><s:textfield id="particularpetty" name="particularpetty"/></td>
                                <td><s:textfield id="docnumpetty" name="docnumpetty"/></td>
                                <td><s:textfield id="docdatepetty" name="docdatepetty"/></td>
                                <td><s:textfield id="amountpetty" name="amountpetty" cssClass="amountpetty"/></td>
                            </tr>
                        </tbody>
                    </table>
                </s:div>--%>

            </sj:tabbedpanel>
        </s:form>
    </s:elseif>


    <s:div cssStyle="clear:left;float:right">
        <s:if test="view=='yes'">
            <sj:submit id="savereport" value="Save"  button="true" cssClass="ui-state-default" cssStyle="font-size:12px !important;font-family: Tahoma, Geneva, sans-serif !important;" />
        </s:if>
    </s:div>
</div>